import java.util.*;
class Node {
    int val;
    Node next;
    Node random;

    public Node(int val) {
        this.val = val;
        this.next = null;
        this.random = null;
    }
}
public class Text {
    public Node copyRandomList(Node head) {
        Map<Node,Node> hashMap = new HashMap<>();
        Node cur = head;
        while(cur != null) {
            Node node = new Node(cur.val);
            hashMap.put(cur,node);
            cur = cur.next;
        }
        cur = head;
        while(cur != null){
            hashMap.get(cur).next = hashMap.get(cur.next);
            hashMap.get(cur).random = hashMap.get(cur.random);
            cur = cur.next;
        }
        return hashMap.get(head);
    }
    public int singleNumber(int[] nums) {
        Set<Integer> hashset = new HashSet<>();
        for(int i = 0; i < nums.length ;i++) {
            if(!hashset.contains(nums[i])){
                hashset.add(nums[i]);
            }else{
                hashset.remove(nums[i]);
            }
        }
        for(int i = 0; i < nums.length ;i++) {
            if(hashset.contains(nums[i])){
                return nums[i];
            }
        }
        return -1;
    }
    public int numJewelsInStones(String jewels, String stones) {
        int count = 0;
        Set<Character> hashset = new HashSet<>();
        for(int i = 0;i < jewels.length();i++){
            if(!hashset.contains(jewels.charAt(i))){
                hashset.add(jewels.charAt(i));
            }
        }
        for(int i = 0;i < stones.length();i++){
            if(hashset.contains(stones.charAt(i))){
                count++;
            }
        }
        return count;
    }
    public static void main(String[] arag){
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNextLine()){
            String str1 = scanner.nextLine();
            String str2 = scanner.nextLine();
            func(str1,str2);
        }
    }
    public static void func(String str1,String str2){
        str1 = str1.toUpperCase();
        str2 = str2.toUpperCase();
        Set<Character> hashset1 = new HashSet<>();
        Set<Character> hashset2 = new HashSet<>();
        for(int i = 0;i < str2.length() ;i++){
            if(!hashset1.contains(str2.charAt(i))){
                hashset1.add(str2.charAt(i));
            }
        }
        for(int i = 0;i < str1.length() ;i++){
            if(!hashset1.contains(str1.charAt(i)) && !hashset2.contains(str1.charAt(i))){
                hashset2.add(str1.charAt(i));
                System.out.print(str1.charAt(i));
            }
        }
    }

}
